import request from '@/utils/request'

const user = {
  getBaseInfo() {
    return request.get('/system/user/getBaseInfo')
  },
  // 用户密码重置
  updateUserPwd(data) {
    return request.post('/system/user/profile/updatePwd', data)
  },
  // 修改用户个人信息
  updateUserProfile(data) {
    return request.put('/system/user/profile', data)
  },
  updateReviewUser(data){
    return request.post('/system/user/editReview', data)
  },
  checkUserIsDefaultPwd(params){
    return request.get('/system/user/checkUserPassWd', {params})
  },
  onLineList(params){
    return request.get('/system/online/list', {params})
  },
  logoutUser(tokenId){
    return request.post(`/system/online/${tokenId}`)
  },
  selectUserListWithCount(params){
    return request.get(`/system/user/selectUserListWithCount`, {params})
  },
  loginLockList(params){
    return request.get('/system/locklog/list', {params})
  },
  unlockLogin(id){
    return request.get(`/system/locklog/unLock/${id}`)
  },
  xsList(params){
    return request.get(`/system/user/xsList`, {params})
  },
  sendMsg(data){
    return request.post('/system/user/sendMsgByUserId', data)
  }
}

// 查询用户列表
export function listUser(params) {
  return request.get('/system/user/list', {params})
}

// 查询用户详细
export function getUser(id) {
  return request.get(`/system/user/${id}`)
}

// 新增用户
export function addUser(data) {
  return request.post('/system/user', data)
}

// 修改用户
export function updateUser(data) {
  return request.put('/system/user', data)
}

// 删除用户
export function delUser(id) {
  return request.delete(`/system/user/${id}`)
}

// 用户密码重置
export function resetUserPwd(id, password) {
  const data = {
    id,
    password
  }
  return request.put('/system/user/resetPwd', data)
}

// 用户状态修改
export function changeUserStatus(id, status) {
  const data = {
    id,
    status
  }
  return request.put('/system/user/changeStatus', data)
}

// 查询用户个人信息
export function getUserProfile() {
  return request.get('/system/user/profile')
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request.put('/system/user/profile', data)
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request.put('/system/user/profile/updatePwd', data)
}

// 用户头像上传
export function uploadAvatar(data) {
  return request.post('/system/user/profile/avatar', data)
}

// 查询授权角色
export function getAuthRole(id) {
  return request.get(`/system/user/authRole/${id}`)
}

// 保存授权角色
export function updateAuthRole(data) {
  return request.put('/system/user/authRole', data)
}

export default user;
